import java.util.Scanner;

public class exercise {
    public static void main9(String[] args) {
        //求2个整数的最大公约数
        Scanner in = new Scanner(System.in);
        System.out.println("输入两个整数");
        int a = in.nextInt();
        int b = in.nextInt();
        int i = a < b ? a : b;
        while(i > 0){
            if(a % i == 0 && b % i==0){
                System.out.println(i);
                break;
            } else {
                i--;
            }
        }
    }

    public static void main8(String[] args) {
        int num = 7;
        for(int i = 30;i >= 0; i -= 2){
            System.out.print(((num >> i) & 1) + " ");
        }
        System.out.println();
        for(int i = 31;i >= 0;i -=2){
            System.out.print(((num>>i) & 1) + " ");
        }

    }


    public static void main7(String[] args) {
        //获取一个数二进制序列中所有的偶数位和奇数位， 分别输出二进制序列
        int num = 101101011;
        int tmp = num;
        int count = 0;
        String str1 = " ";
        String str2 = " ";
        while(tmp != 0){
            count++;
            tmp /= 10;
        }
        for(int i = 1; i <= count; i++){
            if(i % 2 != 0){ //说明这里为奇数位
                str1 += num % 10;
                num /= 10;
            } else {
                str2 += num % 10;
                num /= 10;
            }
        }
        System.out.println(str1);
        System.out.println(str2);
    }
    public static void main6(String[] args) {
        int code = 12345;
        Scanner in = new Scanner(System.in);
        int i = 0;
        System.out.println("请输入密码");
        while (i < 3) {
            int tr = in.nextInt();
            if (tr == code) {
                System.out.println("登陆成功");
                break;
            } else if (i == 2) {
                System.out.println("输入密码超过3次，登陆失败");
            } else {
                System.out.println("请重新输入");
            }
            i++;
        }
    }
    public static void main5(String[] args) {
        //输出一个整数的每一位，如：123的每一位是3，2，1
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        while(num != 0){
            int tmp = num % 10;
            num /= 10;
            System.out.print(tmp + " ");
        }
    }
    public static void main4(String[] args) {
        //计算1/1-1/2+1/3-1/4+1/5 …… + 1/99 - 1/100 的值
        double sum = 0;
        for(int i = 1; i <= 100; i++){
            sum += 1/(double)i;
        }
        System.out.println(sum);
    }

    public static void main3(String[] args) {
        //1到 100 的所有整数中出现多少个数字9
        int count = 0;
        for(int i = 1; i < 100; i++){
            int tmp = i;
            while(tmp != 0) {
                if (tmp % 10 == 9) {
                    count++;
                }
                tmp /= 10;
            }
        }
        System.out.println(count);
    }


    public static void main2(String[] args) {
        //水仙花数
        for(int i = 0; i < 999999; i++){
            int tmp=i;
            int count = 0;
            int sum = 0;
            //计算数字的位数
            while(tmp != 0){
                count++;
                tmp /= 10;
            }
            //判断是否为水仙花数
            tmp = i;
            while(tmp != 0){
                sum += Math.pow(tmp % 10, count);
                tmp /= 10;
            }
            if(i == sum){
                System.out.println(i);
            }
        }
    }
    //打印素数
    public static void main1(String[] args) {
        for(int n = 2; n < 100; n++){
            int i = 2;
            //从2到n的平方根对n进行取余
            for(; i <= Math.sqrt(n) ; i++){
                if(n % i == 0) {
                    break;
                }
            }
            if(i > Math.sqrt(n)){
                System.out.println(n);
            }
        }
    }


}
